(* Content-type: application/vnd.wolfram.mathematica *)

(*** Wolfram Notebook File ***)
(* http://www.wolfram.com/nb *)

(* CreatedBy='Mathematica 8.0' *)

(*CacheID: 234*)
(* Internal cache information:
NotebookFileLineBreakTest
NotebookFileLineBreakTest
NotebookDataPosition[       157,          7]
NotebookDataLength[      5151,        172]
NotebookOptionsPosition[      4859,        157]
NotebookOutlinePosition[      5251,        174]
CellTagsIndexPosition[      5208,        171]
WindowFrame->Normal*)

(* Beginning of Notebook Content *)
Notebook[{
Cell[BoxData[{
 RowBox[{
  RowBox[{
   RowBox[{"\[CapitalDelta]t", " ", "=", "1"}], ";", " ", 
   RowBox[{"\[CapitalDelta]x", "=", "1"}], ";"}], " ", 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"\[Epsilon]", "[", "i_", "]"}], ":=", "1"}], ";", " ", 
  RowBox[{
   RowBox[{"\[Sigma]", "[", "i_", "]"}], ":=", "1"}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"\[Mu]", "[", "i_", "]"}], ":=", "1"}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"CP", "[", "i_", "]"}], ":=", 
   FractionBox[
    RowBox[{"1", "-", 
     FractionBox[
      RowBox[{
       RowBox[{"\[Sigma]", "[", "i", "]"}], "*", "\[CapitalDelta]t", " "}], 
      RowBox[{"2", "*", 
       RowBox[{"\[Mu]", "[", "i", "]"}]}]]}], 
    RowBox[{"1", "+", 
     FractionBox[
      RowBox[{
       RowBox[{"\[Sigma]", "[", "i", "]"}], "*", "\[CapitalDelta]t", " "}], 
      RowBox[{"2", "*", 
       RowBox[{"\[Mu]", "[", "i", "]"}]}]]}]]}], ";", " ", 
  RowBox[{
   RowBox[{"CQ", "[", "i_", "]"}], ":=", 
   FractionBox[
    FractionBox[
     RowBox[{"\[CapitalDelta]t", " "}], 
     RowBox[{"\[Mu]", "[", "i", "]"}]], 
    RowBox[{"1", "+", 
     FractionBox[
      RowBox[{
       RowBox[{"\[Sigma]", "[", "i", "]"}], "*", "\[CapitalDelta]t", " "}], 
      RowBox[{"2", "*", 
       RowBox[{"\[Mu]", "[", "i", "]"}]}]]}]]}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"CA", "[", "i_", "]"}], ":=", 
    FractionBox[
     RowBox[{"1", "-", 
      FractionBox[
       RowBox[{
        RowBox[{"\[Sigma]", "[", "i", "]"}], "*", "\[CapitalDelta]t", " "}], 
       RowBox[{"2", "*", 
        RowBox[{"\[Epsilon]", "[", "i", "]"}]}]]}], 
     RowBox[{"1", "+", 
      FractionBox[
       RowBox[{
        RowBox[{"\[Sigma]", "[", "i", "]"}], "*", "\[CapitalDelta]t", " "}], 
       RowBox[{"2", "*", 
        RowBox[{"\[Epsilon]", "[", "i", "]"}]}]]}]]}], ";", " ", 
   RowBox[{
    RowBox[{"CB", "[", "i_", "]"}], ":=", 
    FractionBox[
     FractionBox[
      RowBox[{"\[CapitalDelta]t", " "}], 
      RowBox[{"\[Epsilon]", "[", "i", "]"}]], 
     RowBox[{"1", "+", 
      FractionBox[
       RowBox[{
        RowBox[{"\[Sigma]", "[", "i", "]"}], "*", "\[CapitalDelta]t", " "}], 
       RowBox[{"2", "*", 
        RowBox[{"\[Epsilon]", "[", "i", "]"}]}]]}]]}], ";"}], 
  "\[IndentingNewLine]", 
  RowBox[{"(*", 
   RowBox[{"Define", " ", "Ex", " ", "and", " ", "Hy"}], 
   "*)"}]}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"GetEx", "[", 
    RowBox[{"i_", ",", "n_"}], "]"}], ":=", 
   RowBox[{
    RowBox[{
     RowBox[{"CA", "[", "i", "]"}], "*", 
     RowBox[{"Ex", "[", 
      RowBox[{"i", ",", 
       RowBox[{"n", "-", "1"}]}], "]"}]}], "-", 
    RowBox[{
     RowBox[{"CB", "[", "i", "]"}], "*", 
     RowBox[{"(", 
      FractionBox[
       RowBox[{
        RowBox[{"Hy", "[", 
         RowBox[{
          RowBox[{"i", "+", 
           FractionBox["1", "2"]}], ",", 
          RowBox[{"n", "-", 
           FractionBox["1", "2"]}]}], "]"}], "-", 
        RowBox[{"Hy", "[", 
         RowBox[{
          RowBox[{"i", "-", 
           FractionBox["1", "2"]}], ",", 
          RowBox[{"n", "-", 
           FractionBox["1", "2"]}]}], "]"}]}], "\[CapitalDelta]x"], 
      ")"}]}]}]}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"GetHy", "[", 
    RowBox[{"i_", ",", "n_"}], "]"}], ":=", 
   RowBox[{
    RowBox[{
     RowBox[{"CP", "[", "i", "]"}], "*", 
     RowBox[{"Ex", "[", 
      RowBox[{"i", ",", 
       RowBox[{"n", "-", "1"}]}], "]"}]}], "-", 
    RowBox[{
     RowBox[{"CQ", "[", "i", "]"}], "*", 
     RowBox[{"(", 
      FractionBox[
       RowBox[{
        RowBox[{"Ex", "[", 
         RowBox[{
          RowBox[{"i", "+", 
           FractionBox["1", "2"]}], ",", 
          RowBox[{"n", "-", 
           FractionBox["1", "2"]}]}], "]"}], "-", 
        RowBox[{"Ex", "[", 
         RowBox[{
          RowBox[{"i", "-", 
           FractionBox["1", "2"]}], ",", 
          RowBox[{"n", "-", 
           FractionBox["1", "2"]}]}], "]"}]}], "\[CapitalDelta]x"], 
      ")"}]}]}]}], ";"}]}], "Input",
 CellChangeTimes->{{3.5603066299657173`*^9, 3.560306685225795*^9}, {
  3.5603068251495905`*^9, 3.560306918439721*^9}, {3.560306956083374*^9, 
  3.5603069598633795`*^9}}]
},
WindowSize->{904, 761},
WindowMargins->{{118, Automatic}, {Automatic, 62}},
Magnification->1.4000000953674316`,
FrontEndVersion->"8.0 for Microsoft Windows (64-bit) (2011\:5e743\:670815\
\:65e5)",
StyleDefinitions->"Default.nb"
]
(* End of Notebook Content *)

(* Internal cache information *)
(*CellTagsOutline
CellTagsIndex->{}
*)
(*CellTagsIndex
CellTagsIndex->{}
*)
(*NotebookFileOutline
Notebook[{
Cell[557, 20, 4298, 135, 503, "Input"]
}
]
*)

(* End of internal cache information *)
